package com.lucky.common.base;

import java.io.Serializable;
import java.util.List;

public class ResultListVO<T> implements Serializable{
	
	private static final long serialVersionUID = 1L;

	
    /** 成功 */  
    public static final String SUCCESS = "200";
    /**内部服务器错误**/
    public static final String FAIL = "500";
    /** 没有登录 */
    public static final String NOT_LOGIN = "400";
    /** 发生异常 */
    public static final String EXCEPTION = "401";
    /** 系统错误 */
    public static final String SYS_ERROR = "402";
    /** 参数错误 */
    public static final String PARAMS_ERROR = "403";
    /** 不支持或已经废弃 */
    public static final String NOT_SUPPORTED = "410";
    /** AuthCode错误 */
    public static final String INVALID_AUTHCODE = "444";
    /** 太频繁的调用 */
    public static final String TOO_FREQUENT = "445";
    /** 未知的错误 */
    public static final String UNKNOWN_ERROR = "499";
    
	/**
	 * 返回错误码
	 */
	String code;
	/**
	 * 返回错误信息
	 */
	String msg;
	/**
	 * 传入的dto参数
	 */
	BaseDTO dto;
	/**
	 * 返回分页数据
	 */
	List<T> list;
	
	public static ResultListVO<String> fail() {
        return new ResultListVO<String>(FAIL, "请求处理失败", null);
    }
	public static ResultListVO<String> fail(String msg) {
        return new ResultListVO<String>(FAIL, msg, null);
    }
	public static ResultListVO<String> fail(String code, String msg) {
        return new ResultListVO<String>(code, msg, null);
    }
	public ResultListVO(List<T> list){
		this.code = SUCCESS;
		this.msg  = "请求处理成功";
		this.list = list;
	}
	public ResultListVO(List<T> list, BaseDTO dto){
		this.code = SUCCESS;
		this.msg  = "请求处理成功";
		this.list = list;
		this.dto = dto;
	}
	public ResultListVO(String code, String msg, List<T> list){
		this.code = code;
		this.msg  = msg;
		this.list = list;
	}
	public ResultListVO(String code){
		this.code = code;
	}
	
	public ResultListVO(String code, String msg){
		this.code = code;
		this.msg  = msg;
	}

	public static <T> ResultListVO<T> fail(String code, String msg, List<T> list) {
        return new ResultListVO<T>(code, msg, list);
    }
	
	public static <T> ResultListVO<T> success(List<T> list) {
        return new ResultListVO<T> (list);
    }
	
	public static <T> ResultListVO<T> success(List<T> list, BaseDTO dto) {
        return new ResultListVO<T> (list,dto);
    }

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public List<T> getList() {
		return list;
	}

	public void setList(List<T> list) {
		this.list = list;
	}
	public BaseDTO getDto() {
		return dto;
	}
	public void setDto(BaseDTO dto) {
		this.dto = dto;
	}
	
	
	
}
